﻿using GalaSoft.MvvmLight;

namespace Mal.Balades.Admin.ViewModels.VisitViewModels.Dashboard
{
    public class DashboardFilterViewModel : ViewModelBase
    {
        #region Fields
        private string label;
        private int count;
       
			
        private VisitsDashBoardViewModel parent;

        #endregion

        #region Construction / Destruction
        public DashboardFilterViewModel(VisitsDashBoardViewModel parent)
        {
            this.parent = parent;
            this.Count = this.parent.Visits.Count;
            this.Label = "Toutes les visites";
        }
        #endregion

        #region enum, struct, class

        #endregion

        #region Properties
        public VisitsDashBoardViewModel Parent
        {
            get { return parent; }
            private set { parent = value; }
        }

        public string Label
        {
            get { return label; }
            set
            {
                if (label != value)
                {
                    label = value;
                    RaisePropertyChanged("Label");
                }
            }
        }

        public int Count
        {
            get { return count; }
            set
            {
                if (count != value)
                {
                    count = value;
                    RaisePropertyChanged("Count");
                }
            }
        }
        #endregion

        #region Methods
        public virtual bool Filter(object obj)
        {
            VisitDashboardViewModel visit = obj as VisitDashboardViewModel;

            if (string.IsNullOrEmpty(this.Parent.SearchedText))
                return true;

            if (visit.SourceVisit != null && visit.SourceVisit.Title != null)
            {
                return visit.SourceVisit.Title.ToLower().Contains(this.Parent.SearchedText.ToLower());
            }

            return false;
        }
        #endregion

        #region Events

        #endregion


    }
}
